﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using LPV_POS.Module;
using LPV_POS.Baocao;
using LPV_POS.Baocao.Ellic;

 class Mod_baocaodoanhthu_tongquat
    {

        Mod_baocao baocao;
        public void rpt_baocaodoanhthu_tongquat( string path_excel, string tongcong_1, string giamgia, string thuevat, 
                                                                        string thuedichvu, string tientip, string tongcong_2, string tongcong_3, string phuthu, string thu, string chi, string congno, string khuyenmai, decimal dc_tienmat, decimal dc_the) // bc httt, editor: PL, date: 2012.07.25
        {

            bc_doanhthu_1 CrReport = new bc_doanhthu_1();
            try
            {
                
                Mod_header_report header_report = new Mod_header_report();
                header_report.f_header_report(CrReport);

                baocao = new Mod_baocao();

                CrystalDecisions.CrystalReports.Engine.TextObject str_thoigian;
                str_thoigian = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_tungaydenngay"];
                if (Variable.str_tungay != "")
                {
                    str_thoigian.Text = Variable.str_tungay;
                }
                else
                {
                    str_thoigian.Text = "";
                }

                CrystalDecisions.CrystalReports.Engine.TextObject str_tongcongchuatanggiam;
                str_tongcongchuatanggiam = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_tongcong_1"];
                str_tongcongchuatanggiam.Text = tongcong_1;

                CrystalDecisions.CrystalReports.Engine.TextObject str_giamgia;
                str_giamgia = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_giamgiam"];
                str_giamgia.Text = giamgia;

                CrystalDecisions.CrystalReports.Engine.TextObject str_thuevat;
                str_thuevat = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_thuevat"];
                str_thuevat.Text = thuevat;

                CrystalDecisions.CrystalReports.Engine.TextObject str_thuedichvu;
                str_thuedichvu = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_thuedichvu"];
                str_thuedichvu.Text = thuedichvu;

                CrystalDecisions.CrystalReports.Engine.TextObject str_tientip;
                str_tientip = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_tientip"];
                str_tientip.Text = tientip;

                CrystalDecisions.CrystalReports.Engine.TextObject str_phuthu;
                str_phuthu = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_phuthu"];
                str_phuthu.Text = phuthu;

                CrystalDecisions.CrystalReports.Engine.TextObject str_thu;
                str_thu = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_thu"];
                str_thu.Text = thu;

                CrystalDecisions.CrystalReports.Engine.TextObject str_chi;
                str_chi = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_chi"];
                str_chi.Text = chi;

                CrystalDecisions.CrystalReports.Engine.TextObject str_congno;
                str_congno = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_khachhangno"];
                str_congno.Text = congno;

                CrystalDecisions.CrystalReports.Engine.TextObject str_khuyenmai;
                str_khuyenmai = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_khuyenmai"];
                str_khuyenmai.Text = khuyenmai;


                CrystalDecisions.CrystalReports.Engine.TextObject str_tongcongdatanggiam;
                str_tongcongdatanggiam = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_tongcong_2"];
                str_tongcongdatanggiam.Text = tongcong_2;

                CrystalDecisions.CrystalReports.Engine.TextObject str_tongcong_3;
                str_tongcong_3 = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_tongcong_3"];
                str_tongcong_3.Text = tongcong_3;

                CrystalDecisions.CrystalReports.Engine.TextObject str_tientrongket;
                str_tientrongket = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_tientrongket"];
                str_tientrongket.Text = tongcong_3;

                //bc httt, editor: PL, date: 2012.07.25
                CrystalDecisions.CrystalReports.Engine.TextObject str_tienmat;
                str_tienmat = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_tienmat"];
                str_tienmat.Text = dc_tienmat.ToString("N0");

                CrystalDecisions.CrystalReports.Engine.TextObject str_the;
                str_the = (CrystalDecisions.CrystalReports.Engine.TextObject)CrReport.ReportDefinition.ReportObjects["txt_the"];
                str_the.Text = dc_the.ToString("N0");
                //end 2012.07.25


                //   xuat file excel
                ExportOptions CrExportOptions;

                DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
                ExcelFormatOptions CrFormatTypeOptions = new ExcelFormatOptions();
                CrDiskFileDestinationOptions.DiskFileName = path_excel;
                CrExportOptions = CrReport.ExportOptions;
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType = ExportFormatType.Excel;
                CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions = CrFormatTypeOptions;
                CrReport.Export();

            }
            catch (Exception ex)
            {

                CrReport.Dispose();
                Mod_messagebox mess = new Mod_messagebox();
                mess.messagebox_pos("Thông báo", "Xuất báo cáo thành file pdf không thành công", loaithongbao.canhbao.GetHashCode());
                //throw;
            }
            CrReport.Dispose();
        }



    }

